package com.wiscamp.ninechapters.problems.infrastructure.mappers.statistics;

import com.wiscamp.ninechapters.problems.infrastructure.po.statistics.StatisticsMenteePO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;

@Repository
public interface StatisticsMenteeMapper extends JpaRepository<StatisticsMenteePO, Long>, JpaSpecificationExecutor<StatisticsMenteePO> {

    @Query(value = "select e from StatisticsMenteePO e where e.dateYear = :year and e.dateMonth = :month and e.dateDay = :day and e.userId = :userId")
    StatisticsMenteePO findByUser(int year, int month, int day, long userId);

    @Query(value = "select e from StatisticsMenteePO e where e.dateYear = :year and e.userId = :userId")
    Collection<StatisticsMenteePO> findByUserAndYear(int year, long userId);

    @Query(value = "select e from StatisticsMenteePO e where e.dateYear = :year and e.dateMonth = :month and e.userId = :userId")
    Collection<StatisticsMenteePO> findByUserAndMonth(int year, int month, long userId);
}